<?php
use Workerman\Worker;
use Workerman\Lib\Timer;
use Beanstalk\Client;
require_once __DIR__ . '/Workerman/Autoloader.php';
require_once __DIR__ . '/Channel/src/Server.php';
require_once __DIR__ . '/Channel/src/Client.php';
require_once __DIR__ . '/mysql/src/Connection.php';  //mysql组件
require_once __DIR__ . '/Beanstalk/Client.php';

// 创建一个Worker监听2345端口，使用http协议通讯
// $worker = new Worker("websocket://172.17.73.202:9092");
$worker = new Worker("websocket://0.0.0.0:9092");
// 设置实例的名称
$worker->name = 'account';
// 启动4个进程对外提供服务
$worker->count = 2;

$worker->onWorkerStart = function($worker) {
    Channel\Client::connect('127.0.0.1', 2206);
    //创建数据框连接
    global $db;
    // $db = new \Workerman\MySQL\Connection('rm-uf6oi8jxh9hkx6xaeo.mysql.rds.aliyuncs.com', '3306', 'liuyu', 'SUIbian1995', 'bento');


};

$worker->onMessage = function($connection, $data){
	var_dump('ssss');
	Channel\Client::publish('push_all', array(
                'content'          => 'ssssss'
    ));
};

Worker::runAll();
